<template>
  <div>
    <el-collapse-transition>
      <el-card v-if="searchShow" shadow="never" :body-style="{ padding: '20px 10px 0px 20px' }">
        <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
          <el-form-item>
            <el-input v-model="dataForm.templateId" :placeholder="$t('wechatLog.templateId')" clearable></el-input>
          </el-form-item>
          <el-form-item>
            <el-input v-model="dataForm.receiver" :placeholder="$t('wechatLog.receiver')" clearable></el-input>
          </el-form-item>
          <el-form-item>
            <el-select v-model="dataForm.status" :placeholder="$t('wechatLog.status')" clearable>
              <el-option :label="$t('wechatLog.status1')" :value="1"></el-option>
              <el-option :label="$t('wechatLog.status0')" :value="0"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button @click="getDataList()" type="primary">{{ $t('query') }}</el-button>
            <el-button @click="searchReset()">{{ $t('reset') }}</el-button>
          </el-form-item>
        </el-form>
      </el-card>
    </el-collapse-transition>
    <el-card shadow="never" class="aui-card--fill" :style="searchShow?'margin-top: 10px;':''">
      <div class="crud__menu">
        <div class="crud__left">
          <el-form :inline="true">
            <el-form-item>
              <el-button v-if="$hasPermission('wechat:msglog:delete')" type="danger" @click="deleteHandle()">
                {{ $t('deleteBatch') }}</el-button>
            </el-form-item>
          </el-form>
        </div>
        <div class="crud__right">
          <el-button-group>
            <el-button icon="el-icon-search" @click="searchShowHandle()"></el-button>
            <el-button icon="el-icon-refresh" @click="getDataList()"></el-button>
          </el-button-group>
        </div>
      </div>

      <div class="mod-sys__wechatmsglog}">
        <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle"
          style="width: 100%;">
          <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
          <el-table-column prop="configId" :label="$t('wechatLog.templateConfigId')" header-align="center"
            align="center" show-overflow-tooltip></el-table-column>
          <el-table-column prop="templateId" :label="$t('wechatLog.templateId')" header-align="center" align="center"
            show-overflow-tooltip></el-table-column>
          <el-table-column prop="receiver" :label="$t('wechatLog.receiver')" header-align="center" align="center"
            show-overflow-tooltip></el-table-column>
          <el-table-column prop="content" :label="$t('wechatLog.content')" header-align="center" align="center"
            show-overflow-tooltip></el-table-column>
          <el-table-column prop="resultMsg" :label="$t('wechatLog.resultMsg')" header-align="center" align="center"
            show-overflow-tooltip></el-table-column>

          <el-table-column prop="status" :label="$t('wechatLog.status')" sortable="custom" header-align="center"
            align="center" width="100">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.status === 1" size="small">{{ $t('wechatLog.status1') }}</el-tag>
              <el-tag v-else size="small" type="danger">{{ $t('wechatLog.status0') }}</el-tag>
            </template>
          </el-table-column>

          <el-table-column prop="createDate" :label="$t('mail.createDate')" sortable="custom" header-align="center"
            align="center" width="180"></el-table-column>

          <el-table-column :label="$t('handle')" header-align="center" align="center" width="80">
            <template slot-scope="scope">
              <el-button v-if="$hasPermission('msg:wechatRecord:delete')" type="text" icon="el-icon-delete" size="small"
                @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
          layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
          @current-change="pageCurrentChangeHandle">
        </el-pagination>
        <!-- 弹窗, 新增 / 修改 -->
      </div>
    </el-card>
  </div>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/msg/wechatRecord/page',
        getDataListIsPage: true,
        deleteURL: '/msg/wechatRecord',
        deleteIsBatch: true
      },
      dataForm: {
        id: ''
      }
    }
  },
  components: {}
}
</script>
